const fs = require('fs')
const path = require('path')
let prefix = `app`
let prefix2 = `${prefix}_pack`
console.log(__dirname)
if (fs.existsSync(path.join(__dirname, `./${prefix2}.js`))) {
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/${prefix}.so`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/${prefix}.jsc`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/${prefix2}.jsc`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/${prefix}.js`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/${prefix2}.js`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `../dist/package-lock.json`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `./${prefix2}.js`))
    } catch (error) { }
    try {
        fs.unlinkSync(path.join(__dirname, `./${prefix2}-obfuscated.js`))
    } catch (error) { }
    try {
        fs.renameSync(path.join(__dirname, `./${prefix2}-obfuscated.jsc`), path.join(__dirname, `../dist/${prefix}.so`))
    } catch (error) { }
}
prefix = `analysisLicense`
if (fs.existsSync(path.join(__dirname, `./${prefix}.js`))) {
    try {
        fs.unlinkSync(path.join(__dirname, `./${prefix}-obfuscated.js`))
    } catch (error) { }
    try {
        fs.renameSync(path.join(__dirname, `./${prefix}-obfuscated.jsc`), path.join(__dirname, `../dist/${prefix}.so`))
    } catch (error) { }
}